/**
 * 初始化动态尺码表json
 * @param header
 * @param columnData
 * @returns {{dynamicHeaders: [{prop: string, label, sort: number}], dynamicContents: *}}
 */
function generateSingleColumnJSON(header, columnData) {
  const dynamicHeaders = [
    { label: header, prop: "position0", sort: 0 }
  ];

  const dynamicContents = columnData.map(item => {
    return {
      position0: item
    };
  });

  return {
    dynamicHeaders,
    dynamicContents
  };
}

// 表头
const header = "尺码";
// 列数据 后端根据spu查询得出返回尺码数组
const columnData = ["XS", "S", "M", "L", "XL", "2XL"];
// 生成JSON数据
const result = generateSingleColumnJSON(header, columnData);
// 输出结果
console.log(result);
